import pymysql
db = pymysql.co(
    host="localhost",
    user="root",
    password="123456",
    database="sys",
    port=3306,
    charset="utf8")
try:
    with db.cursor() as cursor:
        for i in range(10):
            print(f"请输入第{i+1}个人的信息：")
            username=input("姓名：")
            age=int(input("年龄："))
            sex=input("性别：")
            high=float(input("身高(m)(示例:1.60)："))

        sql="insert into person(username,age,sex,high) values (%s,%s,%s,%s)"
        values=(username,age,sex,high)
        cursor.execute(sql,values)
        db.commit()
        print("数据插入成功")
except Exception as e:
     print("数据插入失败：", e)
finally:
    db.close()